//
//  ViewController.m
//  demo
//
//  Created by 叶青 on 15/6/24.
//  Copyright (c) 2015年 naruto. All rights reserved.
//

#import "ViewController.h"
#import "KDLockTest.h"
#import "KDRuntimeTest.h"
#import "KDExample-Swift.h"

//#import <ReactiveCocoa/RACEXTScope.h>
#import <objc/objc.h>

typedef void(^KDBlockTestAction)(void);
@interface ViewController ()
{
    KDLockTest                  *_people;
    KDRuntimeTest               *_runtimeTestObj;
}
@property (atomic, copy) KDBlockTestAction       testAction;/**测试action**/
@end

@implementation ViewController
#pragma mark - system
+(void)load
{
    [kNBCURLRouterInstance registerScheme:@"ViewController" scheme:@"testpage"];
}
-(instancetype)init
{
    self = [super init];
    if(self){
        
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationItem setTitle:self.nbcRouterParams[@"name"]];
    self.view.backgroundColor = [UIColor whiteColor];
    _people = [KDLockTest new];
    UIButton    *btnTest = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 50)];
    btnTest.backgroundColor = [UIColor blueColor];
    [btnTest setTitle:@"测试" forState:UIControlStateNormal];
    [btnTest setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btnTest addTarget:self action:@selector(onBtnTestClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnTest];
    _runtimeTestObj = [KDRuntimeTest new];
    
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
-(void)dealloc
{
    BCLogDealloc();
}


#pragma mark - 事件
/**
 *  测试按钮点击事件
 *  @param sender:按钮
 *  @return void
 */
- (void)onBtnTestClick:(UIButton *)sender
{
    #pragma mark - weakself
//    @weakify(self);
//    [self setTestAction:^{
//        @strongify(self);
//        self.view.backgroundColor=[UIColor grayColor];
//    }];
    
    #pragma mark - lock
//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        [_people eat:3];
////        [_people dressClothe];
//    });
//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        [_people drink];
////        [_people undressClothe];
//    });
    
    #pragma mark - objc_msgSend
//    int (*okdbjc_msgSend)(id, SEL, int) = (int (*)(id, SEL, int))objc_msgSend;
//    okdbjc_msgSend(self,@selector(kdtest),0);
//    //object msg
//    okdbjc_msgSend(_runtimeTestObj,@selector(kdtest1),0);
//    //class msg
//    okdbjc_msgSend([KDRuntimeTest class],@selector(kdtestClassMethod),1);
    
//    [_runtimeTestObj kdtest];
    
    
    #pragma mark - Swift
    KDSwiftTest *swiftObj=[KDSwiftTest new];
    [swiftObj testWithParam1:1212 withParam2:@"1212"];
    
    
}

@end
